<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
include_once "connect.php";
include_once "sujet.php";
include_once "nicedit.html";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>AP3-SP-les phoques du desert</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="verification.js"></script>	
</head>
<body onLoad="display_c()">

<div id="all">
		<div id="header">	
		<a href="index.php"> Retour vers l'Index </a>		
		<?php
		$connecte=0;
		if(isset($_SESSION["user"]))
		{
			$connecte=1;
		}
		if($connecte==1)
		{
			echo $_SESSION["user"]."<br/>";
		}
		?>
			<div id="image">
			</div>
			
			<div id="barre_choix">
			</div>
			
			<div id="log">
			</div>
			
		</div>
		
		<div id="content">
		
<?php
//modifie le post et le remplace dans la base de données
	?><form name="modifiepost" action="modifierpost.php?id_post=<?php echo $_GET["id_post"];?>" method="post">
	<p>
	<?php
		$reqtitre="SELECT titre FROM AP3_SP_post WHERE id_post=".$_GET['id_post'];
		$restitre=mysql_query($reqtitre);
		$row = mysql_fetch_assoc($restitre);
	?>
	<div id="titremodif">
	<?php
	echo $row["titre"];
	echo"</div>";
	echo"<br/>";
	echo"</p>";
	echo"<p>";	
	echo "<textarea name='contenu' cols='80' rows='10'>";
		$req="SELECT contenu FROM AP3_SP_post WHERE id_post=".$_GET['id_post'];
		$res=mysql_query($req);
		$row = mysql_fetch_assoc($res);
	echo $row["contenu"];
?>
	</textarea>
	</p>
	<input type="submit" name="modifiepost" value="Modifier"/><br/>
	</form>
<?php
if(isset($_POST['modifiepost']))
//réenregistre le post dans la table
{
		$reqmodif="UPDATE AP3_SP_post SET contenu='".$_POST['contenu']."' WHERE id_post=".$_GET['id_post'];
		$resmodif=mysql_query($reqmodif);
		
		
		header("Location: index.php");
}
	?>
		</div>
		
		<div id="footer">
			<div id="ct">
			</div>
			
			<div id="droit">
			Made by Les Phoques Du Désert
			</div>
		</div>
</div>